package cn.whut.glab.web;

import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
import javax.servlet.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class StudentAddServlet
 */
public class StudentAddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public StudentAddServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		if (request.getParameter("Method") == null) {
			request.getRequestDispatcher("/WEB-INF/jsp/StudentList.jsp").forward(request, response);
		}
		else if(request.getParameter("Method").equals("add")){
			//String realpath = request.getSession().getServletContext().getRealPath("/");//获取服务器路径
			String realpath = this.getServletContext().getRealPath("/"); //ServletConfig.getServletContext().getRealPath("/");//获取服务器路径
			//String uploadPath=realpath+"WebContent\\WEB-INF\\upload";
			
			request.getRequestDispatcher("/WEB-INF/jsp/AddStudentList.jsp").forward(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
